package com.company;

import java.sql.*;
import java.util.ArrayList;

/**
 * Created by v on 17-3-9.
 */
public class Select {
    private Connection conn;
    private Statement stat;

    //构造方法用于构造对mysql链接的访问
    public Select(){
        try {
            conn=ConnectMysql.getConnection();
            stat=conn.createStatement();
        }catch (SQLException ex){
            ex.printStackTrace();
        }
    }

    public ArrayList<String> getID(String word) throws SQLException {
        ResultSet rs=stat.executeQuery("SELECT coding FROM dictionary " +
                "WHERE word='"+word+"';");

        ArrayList<String> list=new ArrayList<>();

        while (rs.next()){
            list.add(rs.getString(1));
        }

        rs.close();

        return list;
    }
}